import { createRouter, createWebHistory } from 'vue-router'
import layout from '../views/layout/index.vue'
import login from '../views/login/index.vue'
import register from '../views/register/index.vue'
import goodsDetail from '../views/goodsDetail/index.vue'
import addressManage from '../views/addressManage/index.vue'
import goodsPay from '../views/goodsPay/index.vue'
import pay from '@/views/pay/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: layout,
      children: [
        {
          path: '',
          name: 'home',
          component: () => import('@/views/home/index.vue'),
        },
        {
          path: 'search/:condition',
          name: 'search',
          component: () => import('@/views/search/index.vue')
        },
        {
          path: 'category/:type',
          name: 'category',
          component: () => import('@/views/category/index.vue')
        },
        {
          path: 'cartList',
          name: 'cartList',
          component: () => import('@/views/cartList/index.vue'),
        },
        {
          path:'goodsDetail/:clNo',
          name:'goodsDetail',
          component:goodsDetail,
        },
        {
          path:'addressManage',
          name:'addressManage',
          component:addressManage,
        },
        {
          path:'pay/:order_no',
          name:'pay',
          component:pay,
        },
        {
          path:'goodsPay',
          name:'goodsPay',
          component:goodsPay,
        },
        {
          path: 'user',
          name: 'user',
          redirect: 'user/info',
          component: () => import('@/views/user/index.vue'),
          children: [
            {
              path: 'info',
              name: 'userInfo',
              component: () => import('@/views/user/components/UserInfo.vue')
            },
            {
              path: 'order',
              name: 'userOrder',
              component: () => import('@/views/user/components/UserOrder.vue')
            }
          ]
        }
      ]
    },
    {
      path:'/login',
      name: 'login',
      component:login,
    },
    {
      path:'/register',
      name:'register',
      component:register,
    },

  ],
})

export default router
